package ParallelMachineArrangeImpl;

import SingleMachineArrangeImpl.SingleMachineArrange;

import java.util.List;

public abstract class ParallelMachineArrange {
    static class Artifact{
        int process,remain_process;
        boolean isComplete,isActive;
        int ready;
        int weight;
        int due;

        @Override
        public String toString() {
            return hashCode() + "@{" +
                    "p=" + process +
                    ", r=" + ready +
                    ", w=" + weight +
                    ", d=" + due +
                    '}';
        }
    }
    protected List<Artifact> artifacts,processing_artifacts,removed_artifacts;
    protected int[] process,ready,weight,due;
    int machines = 1;
    public final ParallelMachineArrange setProcess(int[] process) {
        this.process = process;
        return this;
    }
    public final ParallelMachineArrange setReady(int[] ready) {
        this.ready = ready;
        return this;
    }
    public final ParallelMachineArrange setWeight(int[] weight) {
        this.weight = weight;
        return this;
    }
    public final ParallelMachineArrange setDue(int[] due) {
        this.due = due;
        return this;
    }
    public final ParallelMachineArrange setMachines(int machines) {
        this.machines = machines;
        return this;
    }
    public final boolean isComplete(){
        if(artifacts==null) return true;
        for (Artifact artifact : artifacts) {
            if(!artifact.isComplete) return false;
        }
        return true;
    }
    //计算工件总加工时间
    public final int getTotalCompleteTime(List<Artifact> artifacts){
        int t = 0;
        int tt = 0;
        for (Artifact artifact : artifacts) {
            t += artifact.process;
            tt += t;
        }
        return tt;
    }
    public final int getCompleteTime(List<Artifact> artifacts){
        int t = 0;
        for (Artifact artifact : artifacts) {
            t += artifact.process;
        }
        return t;
    }
    public abstract void solve();
    protected static final int COMPLETE = -1;
}
